import os
import sys
import launch_ros.actions

from launch import LaunchDescription,LaunchIntrospector,LaunchService
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch.conditions import IfCondition
from launch.conditions import UnlessCondition
from ament_index_python.packages import get_package_share_directory


#def launch(launch_descriptor, argv):
def generate_launch_description():

    params_file = os.path.join(get_package_share_directory("imu_driver"), "config", "params.yaml")
    
    return LaunchDescription([
        launch_ros.actions.Node(
            package='imu_driver', 
            executable='imu_driver_node', 
            name='imu_driver_node',
            output='screen',
            parameters=[params_file],
            )
    ])

def main(argv):
    ld = generate_launch_description()

    print('Starting introspection of launch description...')
    print('')

    print(LaunchIntrospector().format_launch_description(ld))

    print('')
    print('Starting launch of launch description...')
    print('')

    ls = LaunchService()
    ls.include_launch_description(ld)
    return ls.run()


if __name__ == '__main__':
    main(sys.argv)